d = {'A':1,'B':2,"C":3}
print('dict',d)
print('B:',d.get('B'))
for a in d.values():
	print('key:',a)

#导入Iterable 类型
from collections import Iterable
print(isinstance('ABC',Iterable))

#下标-元素对
for i, value in enumerate(['A','B','C']):
	print('index:%s,value:%s' % (i,value))

#列表生成式
L1 = ['Hello','World',18,'Apple',None]
L2 = [s + m for s in L1 if isinstance(s,str) for m in 'ABC']
print(L2)

L3 = [i for i in range(1,10)]
print(L3)

#生成器
#斐波拉契数列
def fib(max):
	n, a, b = 0, 0, 1
	while(n < max):
#		print(b)
		yield b # generator 生成器
		a, b = b, a+b
		n = n+1
	return 'Done'

#a = input('最大数:')
#f = fib(int(a))

#杨辉三角
def triangles():
	L = [1]
	while True:
		yield L
		L.append(0)
		L = [L[i-1] + L[i] for i in range(len(L))]

n = 0
for t in triangles():
    print(t)
    n = n + 1
    if n == 10:
        break